{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sfusd\n"
     ]
    }
   ],
   "source": [
    "print('sfusd')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pylab import *\n",
    "from pandas import DataFrame, read_excel\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "location = r\"E:\\EMC\\上海交通大学校园卡一卡通数据集\\ACCOUT.xlsx\"\n",
    "df = pd.read_excel(location)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>account</th>\n",
       "      <th>studentcode</th>\n",
       "      <th>gender</th>\n",
       "      <th>yearofbirth</th>\n",
       "      <th>grade</th>\n",
       "      <th>type</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A10261</td>\n",
       "      <td>36157082</td>\n",
       "      <td>女</td>\n",
       "      <td>1988</td>\n",
       "      <td>2013</td>\n",
       "      <td>硕士</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>A11648</td>\n",
       "      <td>92011843</td>\n",
       "      <td>男</td>\n",
       "      <td>1997</td>\n",
       "      <td>2014</td>\n",
       "      <td>本科</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>A12575</td>\n",
       "      <td>74018209</td>\n",
       "      <td>男</td>\n",
       "      <td>1991</td>\n",
       "      <td>2010</td>\n",
       "      <td>本科</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>A12611</td>\n",
       "      <td>58181762</td>\n",
       "      <td>男</td>\n",
       "      <td>1984</td>\n",
       "      <td>2011</td>\n",
       "      <td>硕士</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>A12625</td>\n",
       "      <td>38112091</td>\n",
       "      <td>男</td>\n",
       "      <td>1990</td>\n",
       "      <td>2012</td>\n",
       "      <td>硕士</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  account  studentcode gender  yearofbirth  grade type\n",
       "0  A10261     36157082      女         1988   2013   硕士\n",
       "1  A11648     92011843      男         1997   2014   本科\n",
       "2  A12575     74018209      男         1991   2010   本科\n",
       "3  A12611     58181762      男         1984   2011   硕士\n",
       "4  A12625     38112091      男         1990   2012   硕士"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa = df.head()\n",
    "dfa"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfa['gender'].count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>account</th>\n",
       "      <th>studentcode</th>\n",
       "      <th>gender</th>\n",
       "      <th>yearofbirth</th>\n",
       "      <th>grade</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>type</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>博士</th>\n",
       "      <td>4995</td>\n",
       "      <td>4995</td>\n",
       "      <td>4995</td>\n",
       "      <td>4995</td>\n",
       "      <td>4995</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>本科</th>\n",
       "      <td>15374</td>\n",
       "      <td>15374</td>\n",
       "      <td>15374</td>\n",
       "      <td>15374</td>\n",
       "      <td>15374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>硕士</th>\n",
       "      <td>10492</td>\n",
       "      <td>10492</td>\n",
       "      <td>10492</td>\n",
       "      <td>10492</td>\n",
       "      <td>10492</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      account  studentcode  gender  yearofbirth  grade\n",
       "type                                                  \n",
       "博士       4995         4995    4995         4995   4995\n",
       "本科      15374        15374   15374        15374  15374\n",
       "硕士      10492        10492   10492        10492  10492"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gender = df.groupby(['type'])\n",
    "dfs = gender.count()\n",
    "dfs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ok\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>account</th>\n",
       "      <th>studentcode</th>\n",
       "      <th>gender</th>\n",
       "      <th>yearofbirth</th>\n",
       "      <th>grade</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>type</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>本科</th>\n",
       "      <td>15374</td>\n",
       "      <td>15374</td>\n",
       "      <td>15374</td>\n",
       "      <td>15374</td>\n",
       "      <td>15374</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>硕士</th>\n",
       "      <td>10492</td>\n",
       "      <td>10492</td>\n",
       "      <td>10492</td>\n",
       "      <td>10492</td>\n",
       "      <td>10492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>博士</th>\n",
       "      <td>4995</td>\n",
       "      <td>4995</td>\n",
       "      <td>4995</td>\n",
       "      <td>4995</td>\n",
       "      <td>4995</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      account  studentcode  gender  yearofbirth  grade\n",
       "type                                                  \n",
       "本科      15374        15374   15374        15374  15374\n",
       "硕士      10492        10492   10492        10492  10492\n",
       "博士       4995         4995    4995         4995   4995"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfs['account'].plot(kind = 'pie')\n",
    "print('ok')\n",
    "dfs.sort(columns = 'account', ascending = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.4.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
